﻿//cesium 三维的影响结构数据 -->
// 初始化地图

var PanList = (function () {
    // 初始化
    function PanList() {
        // 属性

    };

    ////
    PanList.prototype.init = function (options) {
        this.loadpan();
    }
    PanList.prototype.loadpan = function (options) {
        var that = this;
        var userdata = {
            "userid": "sgx"
        };
        var htmltmp = "<div class='screenbox fl'>"
            + "<div class='screenTop'>"
            + "<img src='static/app/img/picshow.png'>"
            + "<div class='editbox'>"
            + "<i class='iconfont icon-3' data='{{panid}}' ></i>"
            + "<a  target='_blank' href='edit.html?panid={{panid}}' class ='btn btn-primary btn-sm'>&nbsp; &nbsp; 编辑&nbsp; &nbsp;</a>"
            + "</div >"
            + "</div >"
            + " <div class='screenText'>"
            + " <i class='iconfont icon-iconfontweibiaoti2'></i>{{panname}}"
            + " </div >"
            + " <ul class='screenBottom'>"
            + "      <li><i class='iconfont icon-fuzhi' data='{{panid}}'></i><a target='_blank' href='edit.html?panid={{panid}}'>编辑</a></li>"
            + "      <li><i class='iconfont icon-preview' data='{{panid}}'></i><a target='_blank' href='show.html?panid={{panid}}'>预览</a></li >"
            + "      <li><i class='iconfont icon-fabu' data='{{panid}}'></i><a target='_blank' href='show.html?panid={{panid}}'>发布</a></li >"
            + "    </ul >"
            + " </div >";
        $.ajax({
            type: "POST",
            dataType: "json",
            contentType: "application/json",
            url: "pans/getpanbyuser",
            data: JSON.stringify(userdata),
            success: function (data) {
                console.info(data);
                var htmls = "<div   class='addbtn fl'><a target='_blank' href='template.html' style='text-decoration:none;'><i class='iconfont icon-xinjian'></i><span> &nbsp; &nbsp; 新建可视化&nbsp; &nbsp; </span></a></div>";
                $.each(data, function (i, val) {
                    htmls += Mustache.render(htmltmp, val);
                })
                $("#panslist").html(htmls);
                //
                that.editpan();
            }
        });
    }
    PanList.prototype.editpan = function (options) {
        //新建

       

        //删除
        $(".icon-3").on("click", function (e) {
            var c = this;
            var data = $(this).attr("data");
            layer.confirm('是否删除？', { icon: 3, title: '提示' }, function (index) {
                //do something
                var pandata = {
                    "panid": data
                };
                $.ajax({
                    type: "POST",
                    dataType: "json",
                    contentType: "application/json",
                    url: "pans/delpanbyid",
                    data: JSON.stringify(pandata),
                    success: function (result) {                       

                        $(c).parent().parent().parent().remove();
                        layer.msg('删除完成！');
                    }
                });
                layer.close(index);
            });
        });
       

        //编辑
        $(".icon-fuzhi").on("click", function (e) {
            var data = $(this).attr("data");
            console.info(data);
        });
        //预览
        $(".icon-preview").on("click", function (e) {
            var data = $(this).attr("data");

        });
        //发布
        $(".icon-fabu").on("click", function (e) {
            var data = $(this).attr("data");
            console.info(data);
        });

    }
    // 返回
    return PanList;
})();
var panlist;
$(function () {
    panlist = new PanList();
    panlist.init();
})
